<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 关闭广告 */
        .div {
            width: 600px;
            position: relative;

        }

        .div span {
            position: absolute;
            top: 0;
            right: -17px;
            display: block;
            width: 15px;
            height: 15px;
            line-height: 15px;
            color: #fff;
            text-align: center;
            background-color: rgba(0, 0, 0, 0.289);
            border: 1px solid black;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <!-- 开光灯 -->
    <button>开关</button>

    <!-- 关闭广告 -->
    <div class="div">
        <img src="/pink/imgs/彭于晏.png" alt="">
        <span>X</span>
    </div>

    <!-- 输入框 -->
    <input type="text" value="胡歌">
    <script>
        //开光灯
        var body = document.body;
        var btn = document.querySelector('button');
        //开光灯
        var flag = true;
        btn.onclick = () => {
            if (flag == true) {
                body.style.backgroundColor = 'black'
                flag = false;
            } else {
                body.style.backgroundColor = '#fff'
                flag = true;
            }
        }

        //    关闭广告
        var box = document.querySelector('div')
        var x = document.querySelector('span')
        x.onclick = () => {
            box.style.display = 'none'
        }

        //   输入框
        var ins = document.querySelector('input')
        ins.onfocus = function () {
            if (this.value == '胡歌') {
                this.value = '';
            }
            this.style.color='#333'
            this.style.outlineColor = 'red'
        }
        ins.onblur = function () {
            if (this.value == '') {
                this.value = '胡歌'
            }
            this.style.color='#999'

        }
    </script>
</body>

</html>